<?php

require_once 'common.inc.php';

$dc=new dbstuff;
$dc->connect('211.162.191.190', $dpuser, $dppw, $db_torrent, '1');

//error_reporting(0);
if('show'==$action)
{
	//计算出BCT列表
	
	$countip=0;
	$counttime=0;

	$btcsqlip="select count(*) from woso_count where id in (select id from woso_count group by ip)";
	$btcqueryip=$dc->query($btcsqlip);
	$countip = $dc->result($btcqueryip,0);
	$btcsqltime="select count(*) from woso_count";
	$btcquerytime=$dc->query($btcsqltime);
	$counttime = $dc->result($btcquerytime,0);
	include_once MCC_ROOT.'/templates/msystem/traffic.htm';
}
elseif('search'==$action)
{
	
	if($stime>$etime)
		{
			adminmsg('时间参数错误','count.inc.php?action=show');	
		}
	else
	{	
	//IP来源
		//$cnum=array();//查询数据结果
		$countip=0;
		$counttime=0;

		
	
		$stimeo=GmtToUnix($stime);
		$etimeo=GmtToUnix($etime);
		
		
		
		
		//$sqli="select count(ip),count(time) num from woso_count where uptime>='$stime' and uptime<='$etime'";
		//$sqlt="select count(ip),count(time) num from woso_count where uptime>='$stime' and uptime<='$etime'";
		//print $sql;
		$btcsqlip="select count(*) from woso_count where id in (select id  from woso_count where time>='$stimeo' and time<='$etimeo' group by ip)";
		$btcqueryip=$dc->query($btcsqlip);
		$countip = $dc->result($btcqueryip,0);
		$btcsqltime="select count(*)  from woso_count where time>='$stimeo' and time<='$etimeo'";
		$btcquerytime=$dc->query($btcsqltime);
		$counttime = $dc->result($btcquerytime,0);	
		}
	
	include_once MCC_ROOT.'/templates/msystem/traffic.htm';
}
function GmtToUnix($GmtDate)
{
 $DateArr = explode(' ',$GmtDate); 


 $pDate = split('[/.-]',$DateArr[0]);
 $Year = $pDate[0];
 $Month = $pDate[1];
 $Day = $pDate[2];
 

 $pTime = split('[:.-]',$DateArr[1]);
 $Hour = $pTime[0];
 $Minute = $pTime[1];
 $Second = $pTime[2];
 
 if($Year == '' || !is_numeric($Year))$Year = 0;
 if($Month == '' || !is_numeric($Month))$Month = 0;
 if($Day == '' || !is_numeric($Day))$Day = 0;
 if($Hour == '' || !is_numeric($Hour))$Hour = 0;
 if($Minute == '' || !is_numeric($Minute))$Minute = 0;
 if($Second == '' || !is_numeric($Second))$Second = 0;
 return mktime($Hour,$Minute,$Second,$Month,$Day,$Year);
}
?>
